<?php
namespace Model;



use Model\Factory\TableGatewayFactory;

class Unit extends AbstractModel
{
    public $id;
    public $created_date;
    public $created_by;

    private $arrOfUnitLang = array();

    public function getUnitLang($lang){
        if(!$this->arrOfUnitLang[$lang]){
            $unitLangTable = TableGatewayFactory::getUnitLangTable();
            $unitLang = $unitLangTable->getByUnitAndLang($this->id, $lang);
            $this->arrOfUnitLang[$lang] = $unitLang;
        }
        return $this->arrOfUnitLang[$lang];
    }

    public function getName($lang){
        return $this->getUnitLang($lang)->name;
    }
}
